from fastapi import FastAPI, APIRouter
from pydantic import BaseModel
from routers import users, test, other
from typing import Any, Optional


# from middleware.time import get_time
app = FastAPI()

router = APIRouter()


class CommonResponseModel(BaseModel):
    success: bool
    data: Optional[Any] = None
    message: Optional[str] = None


@router.get("/")
async def root():
    return {"message": "Hello World"}

# 添加其他子路由
router.include_router(test.router, tags=["test"])
router.include_router(users.router)
router.include_router(other.router)

# app.middleware("http")(get_time)
# 添加统一路由前缀
app.include_router(router, prefix="/api")


if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app='main:app', host="0.0.0.0", port=8000, reload=True)
